﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace TowerDefence
{
    public class Waypoints : MonoBehaviour
    {
        public static Transform[] points;     // 存储路径点的数组
        public static Transform[] points01;   // 存储路径点01的数组
        public static Transform[] points02;   // 存储路径点02的数组
        public static Transform[] points03;   // 存储路径点03的数组
        public static Transform[] points04;   // 存储路径点04的数组

        public Transform waypoints;          // 路径点的父对象
        public Transform waypoints01;        // 路径点01的父对象
        public Transform waypoints02;        // 路径点02的父对象
        public Transform waypoints03;        // 路径点03的父对象
        public Transform waypoints04;        // 路径点04的父对象

        void Awake()
        {
            // 初始化路径点数组
            points = new Transform[waypoints.childCount];

            // 填充路径点数组
            for (int i = 0; i < points.Length; i++)
            {
                points[i] = waypoints.GetChild(i);
            }

            // 如果路径点01为空，直接返回
            if (waypoints01 == null)
                return;

            // 初始化路径点01数组
            points01 = new Transform[waypoints01.childCount];

            // 填充路径点01数组
            for (int i = 0; i < points01.Length; i++)
            {
                points01[i] = waypoints01.GetChild(i);
            }

            // 如果路径点02为空，直接返回
            if (waypoints02 == null)
                return;

            // 初始化路径点02数组
            points02 = new Transform[waypoints02.childCount];

            // 填充路径点02数组
            for (int i = 0; i < points02.Length; i++)
            {
                points02[i] = waypoints02.GetChild(i);
            }

            // 如果路径点03为空，直接返回
            if (waypoints03 == null)
                return;

            // 初始化路径点03数组
            points03 = new Transform[waypoints03.childCount];

            // 填充路径点03数组
            for (int i = 0; i < points03.Length; i++)
            {
                points03[i] = waypoints03.GetChild(i);
            }

            // 如果路径点04为空，直接返回
            if (waypoints04 == null)
                return;

            // 初始化路径点04数组
            points04 = new Transform[waypoints04.childCount];

            // 填充路径点04数组
            for (int i = 0; i < points04.Length; i++)
            {
                points04[i] = waypoints04.GetChild(i);
            }
        }

    }
}
